//
//  IndexTabBarVC.m
//  YunFu
//
//  Created by Bager on 2018/8/29.
//  Copyright © 2018年 yunfu. All rights reserved.
//

#import "IndexTabBarVC.h"

#import "IndexVC.h"
#import "ZTNavigationViewController.h"

@interface IndexTabBarVC ()

@end

@implementation IndexTabBarVC

- (void)viewDidLoad
{
    self.tabBar.barTintColor = [UIColor whiteColor];
    self.tabBar.tintColor = HexColor(0x02bef7);
    
    [self loadViewControllers];
    
    [super viewDidLoad];
}

- (void)loadViewControllers
{
    IndexVC *index = [[IndexVC alloc] init];
    UIImage * normalImageO = [[UIImage imageNamed:@"yf1-botnav5"]  imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    UIImage * selectImageO = [[UIImage imageNamed:@"yf1-botnav1"]  imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    UITabBarItem * firstTabBarItem = [[UITabBarItem alloc]initWithTitle:@"首页" image:normalImageO selectedImage:selectImageO];
    ZTNavigationViewController *firstNav = [self getNavWithVC:index];
//    firstNav.navigationBarHidden = YES;
    firstNav.tabBarItem = firstTabBarItem;
    
    IndexVC *actor = [[IndexVC alloc] init];
    UIImage * normalImageT = [[UIImage imageNamed:@"yf1-botnav6"]  imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    UIImage * selectImageT = [[UIImage imageNamed:@"yf1-botnav2"]  imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    UITabBarItem * secondTabBarItem = [[UITabBarItem alloc]initWithTitle:@"分类" image:normalImageT selectedImage:selectImageT];
    ZTNavigationViewController *secondNav = [self getNavWithVC:actor];
    secondNav.navigationBarHidden = YES;
    secondNav.tabBarItem = secondTabBarItem;
    
    IndexVC *rank = [[IndexVC alloc] init];
    UIImage * normalImageR = [[UIImage imageNamed:@"yf1-botnav7"]  imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    UIImage * selectImageR = [[UIImage imageNamed:@"yf1-botnav3"]  imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    UITabBarItem * thirdTabBarItem = [[UITabBarItem alloc]initWithTitle:@"发现" image:normalImageR selectedImage:selectImageR];
    ZTNavigationViewController *thirdNav = [self getNavWithVC:rank];
    thirdNav.navigationBarHidden = YES;
    thirdNav.tabBarItem = thirdTabBarItem;
    
    IndexVC *mine = [[IndexVC alloc] init];
    UIImage * normalImageF = [[UIImage imageNamed:@"yf1-botnav8"]  imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    UIImage * selectImageF = [[UIImage imageNamed:@"yf1-botnav4"]  imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    UITabBarItem * forthTabBarItem = [[UITabBarItem alloc]initWithTitle:@"我的" image:normalImageF selectedImage:selectImageF];
    ZTNavigationViewController *forthNav = [self getNavWithVC:mine];
    forthNav.navigationBarHidden = YES;
    forthNav.tabBarItem = forthTabBarItem;
    
    NSArray *controllersArray = @[firstNav, secondNav, thirdNav, forthNav];
    [self setViewControllers:controllersArray animated:YES];
    
    //    self.selectedIndex = 3;
}

- (ZTNavigationViewController *)getNavWithVC:(UIViewController *)vc
{
    ZTNavigationViewController *nav = [[ZTNavigationViewController alloc] initWithRootViewController:vc];
    nav.navigationBar.translucent = NO;
    nav.navigationBar.barTintColor = kPublicColorMain;
    [nav.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName : [UIColor whiteColor]}];
    UIBarButtonItem *temporaryBarButtonItem = [[UIBarButtonItem alloc] init];
    temporaryBarButtonItem.title = @"";
    nav.navigationItem.leftBarButtonItem = temporaryBarButtonItem;
    [nav.interactivePopGestureRecognizer setEnabled:NO];

    return nav;
}


@end
